import { get, post, patch, deleteR } from "@/http/request";
import type { IGuide } from "./type";

// 查询招生简章
export const getList = async (params: any) => {
	return get<any>({}, "/guide/", params);
};

//新增招生简章
export const addGuide = async (data: FormData) => {
	return post<any>(
		{
			headers: { "Content-Type": "multipart/form-data" },
		},
		"/guide",
		data,
	);
};

//更新招生简章
export const updateGuide = async (data: FormData) => {
	const id = data.get("id"); // 从 FormData 中取 id
	console.log(data);

	// 从 FormData 中删除 id，防止发送到后端
	data.delete("id");

	return patch<any>(
		{
			headers: { "Content-Type": "multipart/form-data" },
		},
		`/guide/${id}`,
		data,
	);
};

// 删除用户
export const delGuide = async (id: number) => {
	return deleteR<any>({}, `/guide/${id}`);
};
